package
{
	import com.pblabs.engine.PBE;
	
	import flash.display.LoaderInfo;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuItem;
	
	import helper.ValueObject;
	
	import screen.ManulifeScreen;
	import screen.PreLoaderScreen;
	
	[SWF(width="1076", height="450", frameRate="24")]
	//[SWF(width="600", height="450", frameRate="24")]
	public class Manulife extends MovieClip
	{
		public static var instance:Manulife;
		private var _preloader_screen:PreLoaderScreen;
		private var _cami_screen:ManulifeScreen;
		public function Manulife()
		{
			
			super (); 
			if(instance == null){
				instance = this;
			}
			if (stage) startGame();
			else addEventListener(Event.ADDED_TO_STAGE, startGame);
		}
		
		public static function getInstance():Manulife{
			if(instance == null){
				instance = new Manulife();
			}
			return instance;
		}
		private function startGame(e:Event=null):void{
			/*var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
			
			if (paramObj) {
				//ValueObject.user_name = paramObj.username;
				//ValueObject.pass_word = paramObj.token;
			} else {
				trace('Không tìm thấy params');
			}*/
			PBE.startup(this);
			_cami_screen = new ManulifeScreen();
			addChild(_cami_screen);
			_preloader_screen = new PreLoaderScreen();
			_preloader_screen.onShow();
			addChild(_preloader_screen);
			
			stage.align     = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			
			//setup Right click
			var myMenu :ContextMenu = new ContextMenu();
			myMenu.hideBuiltInItems();
			var my_version:ContextMenuItem = new ContextMenuItem("AntHill 1.0");
			my_version.enabled = false;
			var my_powered:ContextMenuItem = new ContextMenuItem("Powered by Cami Studios");
			my_powered.enabled = false;
			myMenu.customItems.push(my_version, my_powered);
			//contextMenu = myMenu;
			
		}
		public function get preLoaderScreen():PreLoaderScreen{
			return _preloader_screen;
		}
		public function get camiScreen():ManulifeScreen{
			return _cami_screen;
		}
		
	}
}